<?php

namespace App\Http\Requests\Entity\Asset\Video\Media;

use App\Http\Requests\Request;

class VifileRequest extends Request
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
            case 'DELETE':
                {
                    return [];
                }
            // Crate
            case 'POST':
                {
                    return [
                        'sp_id'         => 'required|max:10',
                        'resolution_id' => 'required|max:100',
                        'vfileext_id'   => 'required|max:100',
                        'title'         => 'max:100',
                        'subtitle'      => 'max:100',
                        'name'          => 'required|max:100',
                        'alias_name'    => 'required|max:100',
                        'path'          => 'required|max:100',
                        // 'size'          => 'required',
                        // 'md5'           => 'required',
                        'duration'      => 'required',
                        'href'          => 'required|max:200',
                        'short_desc'    => 'required|max:100',
                        'type'          => 'required',
                        'listorder'     => 'required',
                    ];
                }
            // UPDATE
            case 'PUT':
            case 'PATCH':
                {
                    // $id = $this->route('vifiles');
                    return [
                        'sp_id'         => 'required|max:10',
                        'resolution_id' => 'required|max:100',
                        'vfileext_id'   => 'required|max:100',
                        'title'         => 'max:100',
                        'subtitle'      => 'max:100',
                        'name'          => 'required|max:100',
                        'alias_name'    => 'required|max:100',
                        'path'          => 'required|max:100',
                        // 'size'          => 'required',
                        // 'md5'           => 'required',
                        'duration'      => 'required',
                        'href'          => 'required|max:200',
                        'short_desc'    => 'required|max:100',
                        'type'          => 'required',
                        'listorder'     => 'required',
                    ];
                }
            default:
                break;
        }
    }
    public function messages()
    {
        return [
            'name.required'          => '名称 不能为空',
            'short_desc.required'    => '简述 不能为空',
            'title.max'              => '标题 不能大于100个字符',
            'subtitle.max'           => '副标题 不能大于100个字符',
            'sp_id.required'         => '服务商 不能为空',
            'resolution_id.required' => '清晰度 不能为空',
            'vfileext_id.required'   => '文件扩展名 不能为空',
            'path.required'          => '文件路径 不能为空',
            'href.required'          => '下载路径 不能为空',
            'listorder.required'     => '排序 不能为空',
        ];
    }
}
